/*
 * @lc app=leetcode.cn id=237 lang=java
 *
 * [237] 删除链表中的节点
 */

// @lc code=start
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    /**
     * Accepted
    41/41 cases passed (0 ms)
    Your runtime beats 100 % of java submissions
    Your memory usage beats 99.79 % of java submissions (40.1 MB)
     */
    public void deleteNode(ListNode node) {
        ListNode pre = null;
        while (node.next != null) {
            node.val = node.next.val;
            pre = node;
            node = node.next;
        }
        if (pre != null) {
            pre.next = null;
        }
    }
}
// @lc code=end
